package com.dingteam.question.common.dto;

import com.dingteam.question.common.enums.ModuleEnum;
import com.dingteam.question.common.validation.constraints.ModuleType;
import com.dingteam.question.common.validation.constraints.TextType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Getter
@Setter
@ToString
public class QuestionPaperVerifyDTO implements Serializable {

	private static final long serialVersionUID = -2940195155651825720L;

	@Valid
	@NotEmpty
	private List<QuestionItemDTO> items;


	@Data
	public static class QuestionItemDTO implements Serializable {

		private static final long serialVersionUID = 1979511966488268605L;

		/**
		 * 组件标签内容
		 */
		@NotNull
		private String label;


		/**
		 * 控件的类型
		 * {@link ModuleEnum}
		 */
		@NotBlank
		@ModuleType
		private String moduleType;

		/**
		 * 是否必填
		 */
		private Boolean required;

		/**
		 * 随机顺序
		 */
		private Boolean randomOrder;

		/**
		 * 最大选项 最大长度等
		 */
		private Integer max;

		/**
		 * 最小选项 最小长度等
		 */
		private Integer min;

		/**
		 * 问答控件的填写类型
		 */
		@TextType
		private String textType;

		/**
		 * 控件的内容 标识等数据
		 */
		private String content;

		/**
		 * 是否多选，配合人员控件使用
		 */
		private Boolean multi;

		/**
		 * 选项列表
		 */
		@Valid
		@Size(min = 2, max = 100)
		private List<QuestionItemOptionDTO> options;

	}

	@Data
	public static class QuestionItemOptionDTO implements Serializable {

		private static final long serialVersionUID = 4915636885769008409L;

		/**
		 * 选项内容
		 */
		private String text;

		/**
		 * 图片地址
		 */
		private String imageUrl;

		/**
		 * 数据的存在 如人员ID
		 */
		private String dataId;

		/**
		 * 是否是其他选项 true 其他选项
		 */
		@NotNull
		private Boolean otherFlag;
	}


}
